<!-- <?php
include_once("./Db_pdo.class.php");


ini_set('date.timezone','Asia/Shanghai');
// $DB=new Db_pdo("jmshop","root","root");
// $DB=new Db_pdo("cxh_v3_test","cxhv3","cxhv3pwd!@#");
$DB=new Db_pdo("cxh_v3","cxhv3","cxhv3pwd!@#");
echo '<pre>';


//车补流水 

$car_cash_log = unserialize(file_get_contents('car_log.txt')); 
$new_arr  =array();
// print_r($car_cash_log);
// exit;
foreach ($car_cash_log as $key => $value) {
	if($value['aplc_totel_retime']){
		// $param['bus_id'] = $value['id'];
		$param['member_id'] = $value['member_id'];

		if($value['aplc_totel_days']==2000){
			$ratio =0.0005;
		}else if($value['aplc_totel_days']==1667){
			$ratio =0.0006;
		}
		$param['cash_old'] =0;
		$param['cash_now'] =$value['aplc_totel_money']*$ratio;
		$param['cash_num'] = $value['aplc_totel_money']*$ratio;
		for($i=1;$i<=$value['aplc_totel_retime'];$i++){
			$param['ctime'] = time()-86400*$i;
			$param['remark'] = '[车辆补贴返款] 补贴总金额'.date('Y-m-d',$param['ctime']);
			$new_arr[] = $param;
		}

		
		//判断是否有维护费
		if($value['aplc_re_fee_p']){
			$param1['member_id'] =$value['member_id'];
			$param1['cash_old'] =$value['aplc_totel_money']*$ratio;
			$param1['cash_now'] =$value['aplc_totel_money']*$ratio*0.8;
			$param1['cash_num'] = '-'.$value['aplc_totel_money']*$ratio*0.2;
			for($s=1;$s<=$value['aplc_totel_retime'];$s++){
				$param1['ctime'] = time()-86400*$s;
				$param1['remark'] = '[车辆补贴返款] 扣除个人所得税'.date('Y-m-d',$param1['ctime']);
				$new_arr1[] = $param1;
			}
			
		}
	}
	
}
$arr =array_chunk($new_arr, 5000);
foreach ($arr as $v) {

	$sql = "INSERT INTO ims_cxh_cash_log (`cash_bus_type`,`cash_type`,`cash_now`,`cash_old`,`cash_num`,`remark`,`member_id`,`ctime`) VALUES ";
	foreach ($v as $value) {
		$param2['cash_bus_type'] = 1;
		$param2['cash_type'] =1;

		$param2['cash_now'] =$value['cash_now'];
		$param2['cash_old'] = 0;
		$param2['cash_num'] ='+'.$value['cash_now'];
		$param2['remark'] =$value['remark'];
		$param2['member_id'] = $value['member_id'];
		$param2['ctime'] = $value['ctime'];

		$values="('".implode("','",array_values($param2))."'),";
		$sql .= $values;
	}
	$sql = rtrim($sql, ",");
	// echo $sql;
	$DB->new_query($sql);
	
}
$arr1 =array_chunk($new_arr1, 5000);
foreach ($arr1 as $v1) {

	$sql1 = "INSERT INTO ims_cxh_cash_log (`cash_bus_type`,`cash_type`,`cash_now`,`cash_old`,`cash_num`,`remark`,`member_id`,`ctime`) VALUES ";
	foreach ($v1 as $value1) {
		$param3['cash_bus_type'] = 1;
		$param3['cash_type'] =1;

		$param3['cash_now'] =$value1['cash_now'];
		$param3['cash_old'] = $value1['cash_old'];
		$param3['cash_num'] ='+'.$value1['cash_now'];
		$param3['remark'] =$value1['remark'];
		$param3['member_id'] = $value1['member_id'];
		$param3['ctime'] = $value1['ctime'];

		$values1="('".implode("','",array_values($param3))."'),";
		$sql1 .= $values1;
	}
	$sql1 = rtrim($sql1, ",");
	// echo $sql;
	$DB->new_query($sql1);
	
}























 -->